package com.ruoyi.web.controller.kzgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kzgl.domain.Dzgl;
import com.ruoyi.kzgl.service.IDzglService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电桩管理Controller
 * 
 * @author ruoyi
 * @date 2023-11-23
 */
@RestController
@RequestMapping("/kzgl/dzgl")
public class DzglController extends BaseController
{
    @Autowired
    private IDzglService dzglService;

    /**
     * 查询电桩管理列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dzgl dzgl)
    {
        startPage();
        List<Dzgl> list = dzglService.selectDzglList(dzgl);
        return getDataTable(list);
    }

    @GetMapping("/getnum")
    public Dzgl listnum()
    {
        Dzgl list = dzglService.selectDzglListnum();
        return list;
    }

    /**
     * 导出电桩管理列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:export')")
    @Log(title = "电桩管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dzgl dzgl)
    {
        List<Dzgl> list = dzglService.selectDzglList(dzgl);
        ExcelUtil<Dzgl> util = new ExcelUtil<Dzgl>(Dzgl.class);
        util.exportExcel(response, list, "电桩管理数据");
    }

    /**
     * 获取电桩管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(dzglService.selectDzglByID(ID));
    }

    /**
     * 新增电桩管理
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:add')")
    @Log(title = "电桩管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dzgl dzgl)
    {
        return toAjax(dzglService.insertDzgl(dzgl));
    }

    /**
     * 修改电桩管理
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:edit')")
    @Log(title = "电桩管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dzgl dzgl)
    {
        return toAjax(dzglService.updateDzgl(dzgl));
    }

    /**
     * 删除电桩管理
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dzgl:remove')")
    @Log(title = "电桩管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(dzglService.deleteDzglByIDs(IDs));
    }
}
